package com.truthrock.jpapg;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
// 参考: https://vladmihalcea.com/postgresql-array-java-list/

@Entity //  表示 JPA com.truthrock.springsecurity.entity，没有@Table时，默认@Entity 注释的Class Name = Table Name
@Table(name = "test_array")
@Data // getter/setter
@RequiredArgsConstructor
@NoArgsConstructor
@TypeDef(
    name = "list-array",
    typeClass = ListArrayType.class 
)
public class TestArray {
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO) // 申明自增
    private Integer id;

    @Type(type = "list-array")
    @Column(
        name = "a",
        columnDefinition = "text[]"
    )
    private List<String> a;
}
